package Day5_SampleCodes_Collections;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class CollectionExample {
	public static void main(String[] args) {

		ArrayList<String> c = new ArrayList<String>();

		c.add("Cat");
		c.add("Dog");
		c.add("Fish");
		c.set(2, "Barracude");
		c.add("Cat");
		c.add("Ant");
		c.add("Lion");

		Collections.sort(c);
		for (String element : c) {

			System.out.print(element.toUpperCase() + " ");

		}
		System.out.println("\n");
		// reverse sort
		Collections.sort(c, Collections.reverseOrder());

		System.out.println("REVERSE ORDER " + c);

		String n[] = { new String("water"), new String("ice"),
				new String("qfire"), new String("wind"), new String("WOOD") };

		
		List<String> q = Arrays.asList(n);
		System.out.println("Original order: " + q);
		Collections.sort(q);
		//search
		System.out.println(q);
		int position = Collections.binarySearch(q, "water");
		System.err.println(position + " is the position of wind in the list");
		
		//shuffles
		Collections.shuffle(q);
		System.out.println("Shuffled list " + q);
		
	
	}

}
